run{
  return JavaDialectRuntimeData.class.getProtectionDomain();
}
setUp{
  this.fileManager=new FileManager();
}
tearDown{ }
KPTestLiteral{ }
value{ }
treatCreateMultpleJarAndFileResources{
  createKProjectJar("jar1",true);
  createKProjectJar("jar2",true);
  createKProjectJar("jar3",true);
  createKProjectJar("fol4",false);
  ClassLoader origCl=Thread.currentThread().getContextClassLoader();
    java.io.File file1=fileManager.newFile("jar1.jar");
    java.io.File file2=fileManager.newFile("jar2.jar");
    java.io.File file3=fileManager.newFile("jar3.jar");
    java.io.File fol4=fileManager.newFile("fol4");
    URLClassLoader urlClassLoader=new URLClassLoader(new URL[]{file1.toURL(),file2.toURL(),file3.toURL(),fol4.toURL()});
    Thread.currentThread().setContextClassLoader(urlClassLoader);
    Set<Bean<?>> beans=weld.getBeanManager().getBeans(KProjectTestClass.class,new KPTestLiteral("jar1"));
    Bean bean=(Bean)beans.toArray()[0];
    KProjectTestClass o1=(KProjectTestClass)bean.create(weld.getBeanManager().createCreationalContext(null));
    beans=weld.getBeanManager().getBeans(KProjectTestClass.class,new KPTestLiteral("jar2"));
    bean=(Bean)beans.toArray()[0];
    KProjectTestClass o2=(KProjectTestClass)bean.create(weld.getBeanManager().createCreationalContext(null));
    beans=weld.getBeanManager().getBeans(KProjectTestClass.class,new KPTestLiteral("jar3"));
    bean=(Bean)beans.toArray()[0];
    KProjectTestClass o3=(KProjectTestClass)bean.create(weld.getBeanManager().createCreationalContext(null));
    beans=weld.getBeanManager().getBeans(KProjectTestClass.class,new KPTestLiteral("fol4"));
    bean=(Bean)beans.toArray()[0];
    KProjectTestClass o4=(KProjectTestClass)bean.create(weld.getBeanManager().createCreationalContext(null));
    testEntry(o4,"fol4");
    Thread.currentThread().setContextClassLoader(origCl);
}
testEntry{
  List<String> list=new ArrayList<String>();
  StatelessKnowledgeSession stlsKsession=testClass.getKBase1KSession1();
  stlsKsession.setGlobal("list",list);
  stlsKsession.execute("dummy");
  assertEquals(2,list.size());
  assertTrue(list.contains(jarName + ".test1:rule1"));
  assertTrue(list.contains(jarName + ".test1:rule2"));
  list.clear();
  StatefulKnowledgeSession stflKsession=testClass.getKBase1KSession2();
  stflKsession.setGlobal("list",list);
  stflKsession.fireAllRules();
  assertEquals(2,list.size());
  assertTrue(list.contains(jarName + ".test1:rule1"));
  assertTrue(list.contains(jarName + ".test1:rule2"));
  list.clear();
  stflKsession=testClass.getKBase2KSession3();
  stflKsession.setGlobal("list",list);
  stflKsession.fireAllRules();
  assertEquals(2,list.size());
  assertTrue(list.contains(jarName + ".test2:rule1"));
  assertTrue(list.contains(jarName + ".test2:rule2"));
  list.clear();
  stlsKsession=testClass.getKBase3KSession4();
  stlsKsession.setGlobal("list",list);
  stlsKsession.execute("dummy");
  assertEquals(4,list.size());
  assertTrue(list.contains(jarName + ".test1:rule1"));
  assertTrue(list.contains(jarName + ".test1:rule2"));
  assertTrue(list.contains(jarName + ".test2:rule1"));
  assertTrue(list.contains(jarName + ".test2:rule2"));
}
createKProjectJar{
  kproj.setGroupArtifactVersion(new GroupArtifactVersion("org.test",namespace,"0.1"));
  MemoryFileSystem mfs=new MemoryFileSystem();
  Folder fld2=mfs.getFolder("META-INF");
  fld2.create();
  File fle2=fld2.getFile("beans.xml");
  fle2.create(new ByteArrayInputStream(generateBeansXML(kproj).getBytes()));
  XStream xstream=new XStream();
  String string=xstream.toXML(kproj);
  fle2=fld2.getFile("kproject.xml");
  fle2.create(new ByteArrayInputStream(xstream.toXML(kproj).getBytes()));
  String kBase1R1=getRule(namespace + ".test1","rule1");
  String kBase1R2=getRule(namespace + ".test1","rule2");
  String kbase2R1=getRule(namespace + ".test2","rule1");
  String kbase2R2=getRule(namespace + ".test2","rule2");
  String fldKB1=kproj.getKBasesPath() + "/" + kBase1.getQName()+ "/"+ kBase1.getNamespace().replace('.','/');
  String fldKB2=kproj.getKBasesPath() + "/" + kBase2.getQName()+ "/"+ kBase2.getNamespace().replace('.','/');
  mfs.getFolder(fldKB1).create();
  mfs.getFolder(fldKB2).create();
  mfs.getFile(fldKB1 + "/rule1.drl").create(new ByteArrayInputStream(kBase1R1.getBytes()));
  mfs.getFile(fldKB1 + "/rule2.drl").create(new ByteArrayInputStream(kBase1R2.getBytes()));
  mfs.getFile(fldKB2 + "/rule1.drl").create(new ByteArrayInputStream(kbase2R1.getBytes()));
  mfs.getFile(fldKB2 + "/rule2.drl").create(new ByteArrayInputStream(kbase2R2.getBytes()));
  MemoryFileSystem trgMfs=new MemoryFileSystem();
  MemoryFileSystem srcMfs=mfs;
  fle1.create(new ByteArrayInputStream(generateKProjectTestClass(kproj,namespace).getBytes()));
  List<String> inputClasses=new ArrayList<String>();
  final List<String> classes=compile(kproj,srcMfs,trgMfs,inputClasses);
    writeJar(namespace,trgMfs);
    writeFs(namespace,trgMfs);
}
compile{
  for (  KBase kbase : kproj.getKBases().values()) {
    Folder srcFolder=srcMfs.getFolder(kproj.getKBasesPath() + "/" + kbase.getQName());
    Folder trgFolder=trgMfs.getProjectFolder();
    copyFolder(srcMfs,srcFolder,trgMfs,trgFolder,kproj);
  Folder srcFolder=srcMfs.getFolder("META-INF");
  Folder trgFolder=trgMfs.getFolder("META-INF");
  trgFolder.create();
  System.out.println(classes);
  EclipseJavaCompilerSettings settings=new EclipseJavaCompilerSettings();
  settings.setSourceVersion("1.5");
  settings.setTargetVersion("1.5");
  EclipseJavaCompiler compiler=new EclipseJavaCompiler(settings);
  CompilationResult res=compiler.compile(classes.toArray(new String[classes.size()]),trgMfs,trgMfs);
  if (res.getErrors().length > 0) {
    fail(res.getErrors()[0].getMessage());
}
getRule{
}
copyFolder{
  if (!trgFolder.exists()) {
  Collection<Resource> col=(Collection<Resource>)srcFolder.getMembers();
  for (  Resource rs : srcFolder.getMembers()) {
    if (rs instanceof Folder) {
 else {
      try {
 catch (      IOException e) {
        throw new RuntimeException(e);
}
populateClasses{
  for (  KBase kBase : kproject.getKBases().values()) {
    classes.add(kBase.getNamespace().replace('.','/') + "/" + kBase.getName()+ "Producer.java");
    classes.add(kBase.getNamespace().replace('.','/') + "/" + kBase.getName()+ ".java");
    for (    KSession kSession : kBase.getKSessions().values()) {
      classes.add(kSession.getNamespace().replace('.','/') + "/" + kSession.getName()+ "Producer.java");
      classes.add(kSession.getNamespace().replace('.','/') + "/" + kSession.getName()+ ".java");
}
printFs{
  for (  Resource rs : f.getMembers()) {
    if (rs instanceof Folder) {
}
generateKProjectTestClass{
}
filenameToClassname{
  return filename.substring(0,filename.lastIndexOf(".java")).replace('/','.').replace('\\','.');
}
generateBeansXML{
}
MemoryFileSystemClassLoader{
  super(MemoryFileSystemClassLoader.class.getClassLoader());
}
loadClass{
  Class<?> cls=fastFindClass(name);
    cls=getParent().loadClass(name);
}
fastFindClass{
    if (clazzBytes != null) {
      cls=defineClass(name,clazzBytes,0,clazzBytes.length,PROTECTION_DOMAIN);
}
getResourceAsStream{
  final byte[] clsBytes=this.mfs.read(name);
    return new ByteArrayInputStream(clsBytes);
}
getResource{
  final byte[] clsBytes=this.mfs.read(name);
  if (clsBytes != null) {
      return new URL(null,"memory://" + name,new MemorytURLStreamHandler(clsBytes));
}
getResources{
  return getParent().getResources(name);
}
convertClassToResourcePath{
  return pName.replace('.','/') + ".class";
}
TestWeldSEDeployment{
  super(bootstrap);
}
getBeanDeploymentArchives{
  return Collections.singletonList(beanDeploymentArchive);
}
loadBeanDeploymentArchive{ }
writeFs{
  java.io.File file=fileManager.newFile(outFilename);
  file.mkdir();
  writeFs(mfs,mfs.getProjectFolder(),file);
}
writeFs{
    if (rs instanceof Folder) {
      java.io.File file2=new java.io.File(file1,((Folder)rs).getName());
      file2.mkdir();
 else {
      byte[] bytes=mfs.getFileContents((MemoryFile)rs);
        FileManager.write(new java.io.File(file1,((File)rs).getName()),bytes);
}
writeJar{
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
    ZipOutputStream out=new ZipOutputStream(baos);
    FileManager.write(fileManager.newFile(outFilename + ".jar"),baos.toByteArray());
 catch (  IOException e) {
    e.printStackTrace();
}
writeJarEntries{
  byte[] buf=new byte[1024];
      writeJarEntries(mfs,(Folder)rs,out);
      out.putNextEntry(new ZipEntry(rs.getPath().toPortableString()));
      byte[] contents=mfs.getFileContents((MemoryFile)rs);
      ByteArrayInputStream bais=new ByteArrayInputStream(contents);
      while ((len=bais.read(buf)) > 0) {
        out.write(buf,0,len);
}
